const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const user = new Schema({
  "username": {
    type: String,
    required: [true, '用户名不能为空']
  },
  "password": {
    type: String,
    required: [true, '密码不能为空']
  },
  "mobile": {
    type: String,
    required: [true, '手机号不能为空']
  },
  "orderList": Array,
  "cartList": [{
    "goodsId": String,
    "goodsColor": String,
    "goodsName": String,
    "salePrice": String,
    "goodsImage": String,
    "checked": {
      "type": Boolean,
      "default": false
    },
    "goodsNum": Number
  }],
  "addressList": [{
    "addressId": String,
    "username": String,
    "streetName": String,
    "postCode": Number,
    "tel": String,
    "isDefault": Boolean
  }]
});

module.exports = mongoose.model("users", user);
